<template>
	<view class="test_wrap">
		<y-navbar title="测试api" />
		<u-button type="primary" size="medium" @click="blueTooth">蓝牙</u-button>
		<u-button type="primary" size="medium" @click="getNetwork">网络状态</u-button>
		<u-button type="primary" size="medium" @click="call">拨号</u-button>
		<u-button type="primary" size="medium" @click="sCode">扫码</u-button>
		<u-button type="primary" size="medium" @click="vibrates">振动</u-button>
		<u-button type="primary" size="medium" @click="contact">手机联系人</u-button>
		<u-button type="primary" size="medium" @click="electric">电量</u-button>
		<u-button type="primary" size="medium" @click="soterAuth">生物认证</u-button>
	</view>
</template>

<script>
	export default {
		methods: {
			blueTooth() {
				uni.openBluetoothAdapter({
				  success(res) {
				    console.log(res)
				  }
				})
			},
			
			getNetwork() {
				uni.getNetworkType({
				    success: function (res) {
				        uni.showToast({
				        	icon: 'none',
							title: res.networkType
				        })
				    }
				})
			},
			
			call() {
				uni.makePhoneCall({
					phoneNumber: '13036123349'
				})
			},
			
			sCode() {
				uni.scanCode({
					onlyFromCamera: true,
					success: function(res) {
						uni.showToast({
							icon: 'none',
							title: res.result
						})
					}
				})
			},
			
			vibrates() {
				uni.vibrateLong({
					success: () => {
						
					}
				})
			},
			
			contact() {
				uni.addPhoneContact({
					firstName: '张三',
					mobilePhoneNumber: '12314',
					success: function() {
						uni.showToast({
							icon: 'none',
							title: '添加成功'
						})
					}
				})
			},
			
			electric() {
				console.log(navigator.battery)
				navigator.getBattery().then((battery)=> {
					uni.showToast({
						icon: 'none',
						title: battery
					})
				})
				
			},
			
			soterAuth() {
				uni.startSoterAuthentication({
					requestAuthModes: ['fingerPrint'],
					challenge: '123456',
					authContent: '请用指纹解锁',
					success(res) {
						console.log(res);
					},
					fail(err) {
						console.log(err);
					},
					complete(res) {
						console.log(res);
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.test_wrap {
		padding: 90rpx 0 0;
	}
</style>
